package com.zhoufy.client;

import com.zhoufy.service.RpcRequest;
import com.zhoufy.service.UserService;

/**
 * Created with IntelliJ IDEA by ChouFy on 2020-04-14.
 *
 * @author zhoufy
 */
public class ClientBootStrap {

    public static final String providerName = "UserService#sayHello#";

    public static void main(String[] args) {

        RpcRequest rpcRequest = new RpcRequest();
        rpcRequest.setRequestId("1");
        rpcRequest.setClassName("UserService");
        rpcRequest.setMethodName("isOk");
        rpcRequest.setParameterTypes(new Class<?>[]{String.class});
        rpcRequest.setParameters(new Object[]{"a"});


//        JSONSerializer jsonSerializer = new JSONSerializer();
//        byte[] serialize = jsonSerializer.serialize(rpcRequest);
//        System.out.println(new String(serialize));



        RpcConsumer rpcConsumer = new RpcConsumer();
//
        UserService proxy = (UserService) rpcConsumer.createProxy(UserService.class, rpcRequest);
        System.out.println("----" + proxy.isOk(rpcRequest).getRequestId());




//        while (true){
//            try {
//                // 线程暂停一会
//                TimeUnit.SECONDS.sleep(2);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//            System.out.println(proxy.sayHello("are you ok?"));
//        }


    }
}
